/**
 * 依次添加点，查询第K近
 * 因为K是一个固定的数，所以只保存到目前为止的前K个距离即可
 * 
 */
class Solution {

using llt = long long;
using vll = vector<llt>;
using vi = vector<int>;

public:
    vector<int> resultsArray(vector<vector<int>>& queries, int k) {
        k -= 1;
        vi ans;
        multiset<int> ss;
        int n = queries.size();
        for(int i=0;i<min(n,k);++i){
            ss.insert(abs(queries[i][0]) + abs(queries[i][1]));
            ans.emplace_back(-1);
        }
        for(int i=k;i<n;++i){
            int now = abs(queries[i][0]) + abs(queries[i][1]);
            ss.insert(now);
            if(ss.size() > k + 1) ss.erase(--ss.end());
            ans.emplace_back(*ss.rbegin());
        }
        return ans;
    }
};